
import {
  graphql,
  GraphQLSchema,
  GraphQLBoolean,
  GraphQLObjectType,
  GraphQLString,
  GraphQLID,
  GraphQLList,
  GraphQLNonNull,
  isInputType,
  isOutputType
} from 'graphql';

import mongoose from 'mongoose'
const Info = mongoose.model('Info')


// const parameterType = new GraphQLObjectType({
//   name: 'parameters',
//   fields: {
//     key: {
//       type: GraphQLString
//     },
//     value: {
//       type: GraphQLString
//     }
//   }
// })


const objType = new GraphQLObjectType({
  name: 'mete',
  fields: {
	createdAt: {
	  type: GraphQLString
	},
	updatedAt: {
	  type: GraphQLString
	}
  }
})

export let InfoType = new GraphQLObjectType({
  name: 'Info',
  fields: {
	_id: {
	  type: GraphQLID
	},
	name: {
	  type: GraphQLString
	},
	job: {
	  type: GraphQLString
	},
	school: {
	  type: GraphQLString
	},
	time: {
	  type: GraphQLString
	},
	status: {
	  type: GraphQLString
	},
	phone: {
	  type: GraphQLString
	},
	email: {
	  type: GraphQLString
	},
	meta: {
	  type: objType
	}
  }
})

export const infos = {
  type: new GraphQLList(InfoType),
  args: {},
  resolve (root, params, options) {
	return Info.find({}).exec()
  }
}

export const infoType = {
  type: new GraphQLList(InfoType),
  args: {
	status: {
	  name: 'status',
	  type: new GraphQLNonNull(GraphQLString)
	}
  },
  resolve (root, params, options) {
	return Info.find({
	  status: params.status
	}).exec()
  }
}
